const app = getApp()
import util from '../../../utils/util'
import {
  ColorListDetail
} from '../../../config/api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type: '',
    Imgs: [], // 图片
    ListDetail: {}, //榜单详情
  },
  /**
   * 我要上红榜
   */
  toRed: function () {
    console.log('点击我要上红榜！');
    wx.navigateTo({
      url: "/pages/integralBank/onRedList/onRedList",
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    console.log('options：', options);

    this.setData({
      type: options.type
    })

    let that = this;
    util.apiRequest(ColorListDetail, {
      id: options.id
    }, null).then(r => {
      console.log('榜单详情页面：', r.data.data);
      that.setData({
        ListDetail: r.data.data,
        Imgs: r.data.data.thumb
      });

    });

  },

  // 预览图片
  previewImg: function (e) {
    let that = this;
    //获取当前图片的下标
    var index = e.currentTarget.dataset.index;
    console.log('预览index', index);
    console.log('国家级图片', that.data.Imgs)
    //所有图片
    var imgs = that.data.Imgs;
    console.log('imgs', imgs);
    wx.previewImage({
      //当前显示图片
      current: imgs[index],
      //所有图片
      urls: imgs
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})